<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        let like = "爱好"

        let s1 = Symbol.for('女朋友');
        let s2 = Symbol.for('男朋友');

        let obj = {
            name:"老王",
            age:18,
            [like]:"篮球",
            [s1]:"小花",
            [s2]:"小帅"
        }

        // for in无法遍历symbol属性
        // for(let i in obj){
        //     console.log(i);
        // }

        let arr = Object.getOwnPropertySymbols(obj);
        // console.log(arr);
        arr.forEach(item=>{
            // console.log(item);
            console.log(obj[item]);
        })


        // console.log(obj);


        // let s3 = Symbol(1);

        // console.log(typeof s3);

        // console.log(obj[s2]);
        // console.log(obj[s1]);


        // 如何避免 属性名冲突
        // obj.name = '小李';

        // Symbol - 实现一个独一无二的值
        // console.log(obj);

        // let s1 = Symbol('老王');
        // let s2 = Symbol('老王');

        // console.log(s1);
        // console.log(s1===s2);

        // obj[s1] = '王大拿';
        // obj[s2] = '王小拿';

        // console.log(obj);

        // console.log(obj[s1]);
        // console.log(obj[s2]);




    </script>
</body>
</html>